package com.bargate.domain.spring.expression.value;


import com.bargate.domain.spring.expression.Storm;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.DependsOn;

import java.util.Date;

/**
 * Created by IntelliJ IDEA.
 * User: EAD-MASTER
 * Date: 18/09/2010
 * Time: 21:52:26
 * To change this template use File | Settings | File Templates.
 */
@DependsOn(value = "AnApple")
public class BeanPropertyGetSetOperations {

    private BeanFactory beanFactory;

    @Value("Let me have a 1 #{AnApple.name + AnApple.colorName}")
    private String propertyAccessText;

    public String getPropertyAccessText() {
        return propertyAccessText;
    }

    private Date propertyAccessText4;

//    @Value("#{Hurricane.occurred=25/10/2000}")
    public void setPropertyAccessText4(Date propertyAccessText4) {
        this.propertyAccessText4 = propertyAccessText4;
    }

    
    @Value("A #{Hurricane} is coming")
    private String propertyAccessText2;

    public String getPropertyAccessText2() {
        return propertyAccessText2;
    }

    @Value("Katrina was a #{Hurricane.type} with winds ranging up to #{T(Math).floor(HurricaneKatrina.maxWindVelocity)} Kmh")
    private String propertyAccessText3;

    public String getPropertyAccessText3() {
        return propertyAccessText3;
    }


   @Value("#{Hurricane.distance=10}")
    public void setHurricaneDistance(Double hurricaneDistance) {
    }

    @Value("#{Hurricane.maxWindVelocity=20}")
    public void setMaxWindVelocity(Double maxWindVelocity) {
    }

    @Value("#{Hurricane.harmful=false}")
    public void setHarmful(Boolean harmful) {
    }

    public Double getHurricaneDistance() {
        return ((Storm) beanFactory.getBean("Hurricane")).getDistance();
    }

    public Storm getHurricaneAfterChangesMade() {
        return (Storm) beanFactory.getBean("Hurricane");
    }

    public void setBeanFactory(BeanFactory beanFactory) throws BeansException {
        this.beanFactory = beanFactory;
    }
}
